<template>
  <div class="hello" v-html="text">
  </div>
</template>

<script>
  import wx from 'weixin-js-sdk'
  import { wxInitConfig,wxShareMsg,interface_url,changeImgUrl,setAuthorize} from '../tool'
  import axios from 'axios';

  export default {
    name: 'Index',
    data () {
      return {
        title: '',
        desc:'',
        imgUrl:'',
        text:'',
        id:''
      }
    },
    mounted() {
      wxInitConfig()
      this.id = this.$route.query.id
      this.getArticle()
      console.log("走这个页面")

    },
    methods:{
      sendRedpack(){
        let that=this;
        axios.post(
          interface_url+'/redpack/send',
          {},
        )
          .then(function(response) {

          })
          .catch(function(error) {
            console.log(error);
          });
      },
      getArticle(){
        let that = this;
        console.log(this.id)
        axios.post(
          interface_url+'/redpack/article',
          {
            articleId:"511551896855515137"
          },
        )
          .then(function(response) {
            let data = response.data
            if(data.statusCode == 200){
              that.title = data.data.title
              that.desc = data.data.description
              that.imgUrl = changeImgUrl(data.data.cover)
              that.text = data.data.text;
              console.log( that.text )
              wxShareMsg(that.title, that.desc, that.imgUrl,that.id)
            }else if(data.statusCode == 401){
              setAuthorize(that.id)
            }

          })
          .catch(function(error) {
            console.log(error);
          });
      }
    }
  }
</script>

<style scoped>

</style>
